function inside(fontSize, ifRounding) {
  // 转换单位
  function pointToMM(numIn) {
    return (numIn / 72) * 25.4;
  }
  function MMTopoint(numIn) {
    return (numIn / 25.4) * 72;
  }
  // 格式化数字
  function formatNumForOutput(numIn) {
    return parseFloat(trimEndZero(formatNum(numIn, 2)));
  }
  if (documents.length > 0) {
    var activeDocument = app.activeDocument;
    var elementsSelected = activeDocument.selection;
    if (elementsSelected.length > 0) {
      for (i = 0; i < elementsSelected.length; i++) {
        var targetItem = elementsSelected[i];
        var orginalColor = targetItem.fillColor;
        // 由文档的颜色模式决定颜色的哪些属性可以读取。比如CMYK才有cyan属性。
        // CMYK
        var colorC = orginalColor.cyan;
        var colorM = orginalColor.magenta;
        var colorY = orginalColor.yellow;
        var colorK = orginalColor.black;
        // RGB2
        var colorR = orginalColor.red;
        var colorG = orginalColor.green;
        var colorB = orginalColor.blue;
        // 新建文本
        var outputText = targetItem.parent.textFrames.add();
        // 自动判断文档颜色模式
        var docColorMode;
        if (colorC == undefined) {
          docColorMode = 0;
        }
        if (colorR == undefined) {
          docColorMode = 1;
        }
        // 设置内容
        var textContent = "";
        switch (docColorMode) {
          case 0:
            textContent = colorR + "-" + colorG + "-" + colorB;
            break;
          case 1:
            if (ifRounding) {
              textContent = colorC.toFixed() + "-" + colorM.toFixed() + "-" + colorY.toFixed() + "-" + colorK.toFixed();
            } else {
              textContent = formatNumForOutput(colorC) + "-" + formatNumForOutput(colorM) + "-" + formatNumForOutput(colorY) + "-" + formatNumForOutput(colorK);
            }
            break;
        }
        // 传递文本内容
        outputText.contents = textContent;
        // 设置字体大小
        // var scale = outputText.height / MMTopoint(fontSize);
        // outputText.height = MMTopoint(fontSize);
        // outputText.width /= scale;
        outputText.textRange.characterAttributes.size = MMTopoint(fontSize);
        // 设置字体
        for (n = 0; n < app.textFonts.length; n++) {
          if (app.textFonts[n].name == "MicrosoftYaHei") {
            outputText.textRange.characterAttributes.textFont = app.textFonts[n];
          }
        }
        // 设置文本坐标
        outputText.top = targetItem.top - targetItem.height - outputText.height / 2;
        outputText.left = targetItem.left + targetItem.width / 2 - outputText.width / 2;
        // 重绘
        redraw();
        // 选择生成的文本
        outputText.selected = true;
      }
      // targetItem.selected = false;
    } else {
      alert("请先选中一个物体!");
    }
  } else {
    alert("请先打开一个文档!");
  }
}

function formatNum(numIn, accuracyIn) {
  var tempNum = numIn.toFixed(accuracyIn + 2).slice(0, -1);
  var tempNumString = "" + tempNum;
  var lastNum = parseInt(tempNumString.charAt(tempNumString.length - 1));
  if (lastNum != 0) {
    var zeroString = "";
    var tempString = "";
    for (k = 1; k < accuracyIn; k++) {
      zeroString += "0";
    }
    tempString = "0." + zeroString + "1";
    // 此时area为字符串
    numIn = numIn.toFixed(accuracyIn + 1).slice(0, -1);
    numIn = parseFloat(numIn) + parseFloat(tempString);
  } else {
    numIn = numIn.toFixed(accuracyIn + 1).slice(0, -1);
  }
  return numIn;
}

function trimEndZero(numIn) {
  var originString = "" + numIn;
  numIn = parseFloat(originString);
  return numIn;
}
